/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JOrderFilter.java
 *
 * Created on 2009-11-9, 20:41:10
 */

package cn.ekuma.epos.order;

import cn.ekuma.epos.datalogic.I_DataLogicCustomers;
import cn.ekuma.epos.datalogic.I_DataLogicERP;
import com.openbravo.data.basic.BasicException;
import com.openbravo.beans.JCalendarDialog;
import com.openbravo.data.gui.ComboBoxValModel;
import com.openbravo.data.gui.ListQBFModelNumber;
import com.openbravo.data.gui.MessageInf;
import com.openbravo.data.loader.query.QBFCompareEnum;
import com.openbravo.data.loader.ui.QBFCompareEnumListCellRenderer;
import com.openbravo.data.user.EditorCreator;
import com.openbravo.editor.JEditorKeys;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppLocal;
import com.openbravo.pos.base.AppView;
import com.openbravo.bean.Location;
import com.openbravo.bean.erp.Order;
import com.openbravo.bean.erp.OrderType;
import com.openbravo.bean.TaxCategory;
import com.openbravo.bean.infobean.UserInfo;
import com.openbravo.pos.panels.JCustomerFinder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.DefaultComboBoxModel;

/**
 *
 * @author Administrator
 */
public class JOrderFilter extends javax.swing.JPanel implements EditorCreator{

    private ComboBoxValModel m_CategoryModel,m_OrderTypeModel;
    private I_DataLogicERP dlSales;
    private I_DataLogicCustomers dlCustomers;
    private ComboBoxValModel m_LocationsModel;
    private List orderTypes;
    private AppView app;

    /** Creates new form JOrderFilter */
    public JOrderFilter(AppView app,JEditorKeys m_jKeys,I_DataLogicERP dlSales,I_DataLogicCustomers dlCustomers) {
    	this.app=app;
        this.dlSales =dlSales;
        this.dlCustomers = dlCustomers;
        initComponents();

        jtxtOrderID.addEditorKeys(m_jKeys);
        jtxtMoney.addEditorKeys(m_jKeys);
        initCombos();
        defaultValues();
        if(app.isCustomerView()||dlCustomers==null){
        	btnCustomer.setEnabled(false);
        }
    }

     private void initCombos() {
        String[] values = new String[] {AppLocal.getIntString("label.all"),AppLocal.getIntString("label.orderbearing.normal"),
                    AppLocal.getIntString("label.orderbearing.reverse") };
        jComboBoxOrder.setModel(new DefaultComboBoxModel(values));

        jcboMoney.setModel(ListQBFModelNumber.getMandatoryNumber());
        jcboMoney.setRenderer(new QBFCompareEnumListCellRenderer());
        try {
            orderTypes = dlSales.list(OrderType.class);
        } catch (BasicException ex) {
            ex.getMessage();
           orderTypes=new ArrayList();
        }
        orderTypes.add(0, null);
        m_OrderTypeModel = new ComboBoxValModel(orderTypes);
        jOrderDefineType.setModel(m_OrderTypeModel);

        List locationList=null;
        try {
            locationList=dlSales.list(Location.class);
        } catch (BasicException ex) {
            ex.getMessage();
        }
        locationList.add(0, null);
        m_LocationsModel = new ComboBoxValModel(locationList);
        m_jLocation.setModel(m_LocationsModel); // para que lo refresque

        m_CategoryModel = new ComboBoxValModel();
        List catlist=null;
        try {
            catlist =dlSales.list(UserInfo.class);
        } catch (BasicException ex) {
             new MessageInf(ex).show(this);
        }
        catlist.add(0, null);
        m_CategoryModel = new ComboBoxValModel(catlist);
        jcboUser.setModel(m_CategoryModel);
    }


    public  void defaultValues() {

        jtxtOrderID.reset();
        jtxtOrderID.activate();
        jComboBoxOrder.setSelectedIndex(0);

        jcboUser.setSelectedItem(null);
        m_jLocation.setSelectedItem(null);
        
        jcboMoney.setSelectedItem( ((ListQBFModelNumber)jcboMoney.getModel()).getElementAt(0) );
        jcboMoney.revalidate();
        jcboMoney.repaint();

        jtxtMoney.reset();

        jTxtStartDate.setText(null);
        jTxtEndDate.setText(null);

        if(app.isCustomerView())
        	jtxtCustomer.setText(app.getCustomerInfo().getName());
        else
           jtxtCustomer.setText(null);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel7 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jcboUser = new javax.swing.JComboBox();
        jtxtOrderID = new com.openbravo.editor.JEditorIntegerPositive();
        labelCustomer = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTxtStartDate = new javax.swing.JTextField();
        jTxtEndDate = new javax.swing.JTextField();
        btnDateStart = new javax.swing.JButton();
        btnDateEnd = new javax.swing.JButton();
        jtxtCustomer = new javax.swing.JTextField();
        btnCustomer = new javax.swing.JButton();
        jComboBoxOrder = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jOrderDefineType = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        m_jLocation = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jcboMoney = new javax.swing.JComboBox();
        jtxtMoney = new com.openbravo.editor.JEditorCurrency();

        setLayout(new java.awt.BorderLayout());

        jPanel7.setPreferredSize(new java.awt.Dimension(300, 150));

        jLabel1.setText(AppLocal.getIntString("label.orderid")); // NOI18N

        jLabel6.setText(AppLocal.getIntString("label.user")); // NOI18N

        labelCustomer.setText(AppLocal.getIntString("label.customer")); // NOI18N

        jLabel3.setText(AppLocal.getIntString("Label.StartDate")); // NOI18N

        jLabel4.setText(AppLocal.getIntString("Label.EndDate")); // NOI18N

        jTxtStartDate.setPreferredSize(new java.awt.Dimension(200, 25));

        jTxtEndDate.setPreferredSize(new java.awt.Dimension(200, 25));

        btnDateStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/date.png"))); // NOI18N
        btnDateStart.setPreferredSize(new java.awt.Dimension(50, 25));
        btnDateStart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDateStartActionPerformed(evt);
            }
        });

        btnDateEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/date.png"))); // NOI18N
        btnDateEnd.setPreferredSize(new java.awt.Dimension(50, 25));
        btnDateEnd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDateEndActionPerformed(evt);
            }
        });

        jtxtCustomer.setPreferredSize(new java.awt.Dimension(200, 25));

        btnCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/kuser.png"))); // NOI18N
        btnCustomer.setFocusPainted(false);
        btnCustomer.setFocusable(false);
        btnCustomer.setMargin(new java.awt.Insets(8, 14, 8, 14));
        btnCustomer.setPreferredSize(new java.awt.Dimension(50, 25));
        btnCustomer.setRequestFocusEnabled(false);
        btnCustomer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCustomerActionPerformed(evt);
            }
        });

        jLabel2.setText(AppLocal.getIntString("label.ordertype")); // NOI18N

        jLabel8.setText(AppLocal.getIntString("label.warehouse")); // NOI18N

        jLabel7.setText(AppLocal.getIntString("label.totalcash")); // NOI18N

        javax.swing.GroupLayout gl_jPanel7 = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(gl_jPanel7);
        gl_jPanel7.setHorizontalGroup(
            gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(gl_jPanel7.createSequentialGroup()
                .addContainerGap()
                .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(gl_jPanel7.createSequentialGroup()
                        .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, gl_jPanel7.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE))
                        .addGap(14, 14, 14)
                        .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(m_jLocation, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(gl_jPanel7.createSequentialGroup()
                                .addComponent(jOrderDefineType, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBoxOrder, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_jPanel7.createSequentialGroup()
                                .addComponent(jTxtStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnDateStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_jPanel7.createSequentialGroup()
                                .addComponent(jTxtEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnDateEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(54, 54, 54)
                        .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(gl_jPanel7.createSequentialGroup()
                                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                .addGroup(gl_jPanel7.createSequentialGroup()
                                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                .addGroup(gl_jPanel7.createSequentialGroup()
                                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
                                    .addGap(14, 14, 14)))
                            .addGroup(gl_jPanel7.createSequentialGroup()
                                .addComponent(labelCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(14, 14, 14)))
                        .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtxtOrderID, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)
                            .addGroup(gl_jPanel7.createSequentialGroup()
                                .addComponent(jtxtCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jcboUser, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(gl_jPanel7.createSequentialGroup()
                                .addComponent(jcboMoney, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtxtMoney, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(gl_jPanel7.createSequentialGroup()
                        .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
                        .addGap(670, 670, 670))))
        );
        gl_jPanel7.setVerticalGroup(
            gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(gl_jPanel7.createSequentialGroup()
                .addContainerGap()
                .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jOrderDefineType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jComboBoxOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                        .addComponent(jLabel1)
                        .addComponent(jtxtOrderID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel3)
                    .addComponent(jTxtStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDateStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelCustomer)
                    .addComponent(jtxtCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel6)
                    .addComponent(jcboUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jTxtEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDateEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel8)
                        .addComponent(m_jLocation, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(gl_jPanel7.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jtxtMoney, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jcboMoney, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        add(jPanel7, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

    private void btnDateStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateStartActionPerformed
        Date date;
        try {
            date = (Date) Formats.TIMESTAMP.parseValue(jTxtStartDate.getText());
        } catch (BasicException e) {
            date = null;
        }
        date = JCalendarDialog.showCalendarTimeHours(this, date);
        if (date != null) {
            jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(date));
        }
}//GEN-LAST:event_btnDateStartActionPerformed

    private void btnDateEndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateEndActionPerformed
        Date date;
        try {
            date = (Date) Formats.TIMESTAMP.parseValue(jTxtEndDate.getText());
        } catch (BasicException e) {
            date = null;
        }
        date = JCalendarDialog.showCalendarTimeHours(this, date);
        if (date != null) {
            jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(date));
        }
}//GEN-LAST:event_btnDateEndActionPerformed

    private void btnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCustomerActionPerformed
        JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlSales);
        finder.search(null);
        finder.setVisible(true);

        //try {
            jtxtCustomer.setText(finder.getSelectedCustomer() == null
                    ? null
                    : finder.getSelectedCustomer().getName());// dlSales.loadCustomer(finder.getSelectedCustomer().getId()).toString());
       // } catch (BasicException e) {
          //  MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), e);
           // msg.show(this);
      //  }
    }//GEN-LAST:event_btnCustomerActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCustomer;
    private javax.swing.JButton btnDateEnd;
    private javax.swing.JButton btnDateStart;
    private javax.swing.JComboBox jComboBoxOrder;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JComboBox jOrderDefineType;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JTextField jTxtEndDate;
    private javax.swing.JTextField jTxtStartDate;
    private javax.swing.JComboBox jcboMoney;
    private javax.swing.JComboBox jcboUser;
    private javax.swing.JTextField jtxtCustomer;
    private com.openbravo.editor.JEditorCurrency jtxtMoney;
    private com.openbravo.editor.JEditorIntegerPositive jtxtOrderID;
    private javax.swing.JLabel labelCustomer;
    private javax.swing.JComboBox m_jLocation;
    // End of variables declaration//GEN-END:variables


    @Override
     public Object createValue() throws BasicException {
        Object[] afilter = new Object[18];
        // Order ID
        if (jtxtOrderID.getText() == null || jtxtOrderID.getText().equals("")) {
            afilter[0] = QBFCompareEnum.COMP_NONE;
            afilter[1] = null;
        } else {
            afilter[0] = QBFCompareEnum.COMP_EQUALS;
            afilter[1] = jtxtOrderID.getText();
        }

        //Order DefineType
         if(jOrderDefineType.getSelectedItem()==null){
            afilter[2] = QBFCompareEnum.COMP_NONE;
            afilter[3] = null;
        }else{
            afilter[2] =  QBFCompareEnum.COMP_EQUALS;
            afilter[3]= ((OrderType)jOrderDefineType.getSelectedItem()).getId();
        }

        // Sale and refund checkbox
        if (jComboBoxOrder.getSelectedIndex() == 0) {
            afilter[4] = QBFCompareEnum.COMP_NONE;
            afilter[5] = 2;
        } else if (jComboBoxOrder.getSelectedIndex() == 1) {
            afilter[4] = QBFCompareEnum.COMP_EQUALS;
            afilter[5] = Order.ORDERBEARING_NORMAL;
        } else if (jComboBoxOrder.getSelectedIndex() == 2) {
            afilter[4] = QBFCompareEnum.COMP_EQUALS;
            afilter[5] = Order.ORDERBEARING_REVERSE;
        }

        // Date range
        Object startdate = Formats.TIMESTAMP.parseValue(jTxtStartDate.getText());
        Object enddate = Formats.TIMESTAMP.parseValue(jTxtEndDate.getText());

        afilter[6] = (startdate == null) ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_GREATEROREQUALS;
        afilter[7] = startdate;
        afilter[8] = (enddate == null) ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_LESS;
        afilter[9] = enddate;

        //User
        if (jcboUser.getSelectedItem() == null) {
            afilter[10] = QBFCompareEnum.COMP_NONE;
            afilter[11] = null;
        } else {
            afilter[10] = QBFCompareEnum.COMP_EQUALS;
            afilter[11] = ((TaxCategory)jcboUser.getSelectedItem()).getName();
        }

        //Customer
        if (jtxtCustomer.getText() == null || jtxtCustomer.getText().equals("")) {
            afilter[12] = QBFCompareEnum.COMP_NONE;
            afilter[13] = null;
        } else {
            afilter[12] = QBFCompareEnum.COMP_RE;
            afilter[13] = jtxtCustomer.getText();
        }

        //Location
        if(m_jLocation.getSelectedItem()==null){
            afilter[14] = QBFCompareEnum.COMP_NONE;
            afilter[15] = null;
        }else{
            afilter[14] = QBFCompareEnum.COMP_EQUALS;
            afilter[15] = ((Location)m_jLocation.getSelectedItem()).getID();
        }


        // Receipt money
        afilter[16] = afilter[17] == null ? QBFCompareEnum.COMP_NONE : jcboMoney.getSelectedItem();
        afilter[17] = jtxtMoney.getDoubleValue();

        return afilter;

    }
    
    
    
}
